const { override, addWebpackAlias, fixBabelImports } = require("customize-cra")
const path = require("path");
const rewireCompressionPlugin = require('react-app-rewire-compression-plugin');
// 在这里进行自定义修改相关配置
const replaceConfig = () => (config,env) => {
    // 在这里进行CompressionPlugin的配置
    config = rewireCompressionPlugin(config, env, {
        test: /\.js(\?.*)?$/i,
        cache: true
    })
    // 需要返回config对象
    return config;
};


module.exports=override(
    //引入插件写相关配置
    addWebpackAlias({
        "@" : path.resolve(__dirname, "src")
    }),
    // 按需打包
    fixBabelImports("antd", {
        libraryName: "antd",
        libraryDirectory: "es",
        style: "css",
    }),
    fixBabelImports("react-use", {
        libraryName: "react-use",
        libraryDirectory: "lib",
        camel2DashComponentName: false,
    }),
    replaceConfig()
)